package com.lanou.util;

import lombok.Data;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName R
 * @Description TODO
 * @Author lizhenjiang
 * @Date 2025年07月29日 19:09
 * @Version 1.0
 */
@RestController
@Data
public class R {
    private int code;
    private String msg;
    private Object data;

    public static R ok(){
        R r = new R();
        r.setCode(200);
        r.setMsg("操作成功");
        r.setData(null);
        return r;
    }
    public static R ok(String msg){
        R r = new R();
        r.setCode(200);
        r.setMsg(msg);
        r.setData(null);
        return r;
    }
    public static R ok(Object data){
        R r = new R();
        r.setCode(200);
        r.setMsg("");
        r.setData(data);
        return r;
    }
    public static R fail(String msg){
        R r = new R();
        r.setCode(1);
        r.setMsg(msg);
        r.setData(null);
        return r;
    }
    public static R error(String msg){
        R r = new R();
        r.setCode(-1);
        r.setMsg(msg);
        r.setData(null);
        return r;
    }
}
